#include "FrontEndState.h"
#include "PlayState.h"
#include "Wave2.h"
#include "Wave3.h"
#include <SGE.h> 

using namespace SGE; 

GameContext gameContext;
bool quit = false; 
GameState* currentState = nullptr;
NextState nextState = Frontend;

void SGE_Initialize()
{
	
}

void SGE_Terminate()
{
	
}

bool SGE_Update(float deltaTime)
{
	if (nextState !=None)
	{
		if(currentState!= nullptr)
		{
			currentState->Unload();
			delete currentState;
		}

		switch(nextState)
		{
		case Frontend:
			currentState = new FrontEndState(gameContext);
			break;
		case Gameplay:
			currentState = new PlayState(gameContext);
			break;

		case Wavenumber2:
			currentState = new Wave2(gameContext);
			break;

		case Wavenumber3:
			currentState = new Wave3(gameContext);
			break;

		
	
		}

		if (currentState != nullptr)
		{
			currentState->Load();
		}
	}

	nextState = currentState ->Update(deltaTime);

	if (nextState == Quit)
	{
		currentState->Unload();
		delete currentState;
		return true;
	}

	return false; 
}

void SGE_Render()
{
	currentState->Render();
}